#!/bin/csh
# THIS SUB-SCRIPT IS USED TO MODIFY THE DATA-STATUS FILE.
# NEED setenv datadir
# usage: ./read-status.csh gts 20080301 check
# usage: ./read-status.csh gts 20080301 time
# usage: ./read-status.csh gts 20080301 status

set jobname = $1
set runtime  = $2
set action   = $3
set year = `printf $runtime | cut -c1-4`
set target_file = "$datadir/data-status/$year/data-status.${jobname}.${runtime}.txt"

if ( $action == "check" ) then
    grep $runtime $target_file >& /dev/null
    set result = $?
    printf $result
else if ( $action == "time" ) then
    cat $target_file | awk "/${runtime}"/'{print $1}'
else if ( $action == "status" ) then
    cat $target_file | awk "/${runtime}"/'{print $2}'
endif

